import request from "@/utils/request.ts";
import type {SysResponse} from "@/api/commonType.ts";
import type {registerData} from "@/api/register/type.ts";

enum API {
  VERIFY_USERNAME = "/api/register/verifyUsername",
  VERIFY_PHONE = "/api/register/verifyPhone",
  VERIFY_EMAIL = "/api/register/verifyEmail",
  DO_REGISTER = "/api/register/doRegister",
}


/*
* 校验用户名
* */
export function verifyUsername(username: string) {
  return request.get<string, SysResponse<null>>(API.VERIFY_USERNAME, {
    params: {
      username
    }
  })
}

/*
* 校验手机号
* */
export function verifyPhone(phone: string) {
  return request.get<string, SysResponse<null>>(API.VERIFY_PHONE, {
    params: {
      phone
    }
  })
}
/*
* 校验邮箱
* */
export function verifyEmail(email: string) {
  return request.get<string, SysResponse<null>>(API.VERIFY_EMAIL, {
    params: {
      email
    }
  })
}

/*
* 注册
* */
export function doRegister(data: registerData) {
  return request.post<string, SysResponse<null>>(API.DO_REGISTER, data)
}
